export enum HealthStatus{
    green= "green",
    yellow="yellow",
    red="red"
}

export interface Health {
    properties:Record<string, any>;
    clusterName: string;
    status: HealthStatus;
    numberOfNodes: number;
    numberOfDataNodes: number;
    activePrimaryShards: number;
    activeShards: number;
    relocatingShards: number;
    initializingShards: number;
    unassignedShards: number;
    activeShardsPercentAsNumber: number;
}

export const createHealth = (row: Record<string, any>):Health =>{
    return {
        properties:row,
        clusterName: row["cluster_name"],
        status: row["status"],
        numberOfNodes: row["number_of_nodes"],
        numberOfDataNodes: row["number_of_data_nodes"],
        activePrimaryShards: row["active_primary_shards"],
        activeShards: row["active_shards"],
        relocatingShards: row["relocating_shards"],
        initializingShards: row["initializing_shards"],
        unassignedShards: row["unassigned_shards"],
        activeShardsPercentAsNumber: row["active_shards_percent_as_number"],
    }
}

export const createDefaultHealth = ():Health =>{
    return {
        properties:{},
        clusterName: "",
        status: HealthStatus.green,
        numberOfNodes: 0,
        numberOfDataNodes: 0,
        activePrimaryShards: 0,
        activeShards: 0,
        relocatingShards: 0,
        initializingShards: 0,
        unassignedShards: 0,
        activeShardsPercentAsNumber: 0,
    }
}